﻿using Acme.BookStore.AcmeModel;
using Acme.BookStore.Line;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Acme.BookStore
{
    public class LineServer :
        CrudAppService<
            LineInfo, //The Book entity
            LineInfoDto, //Used to show books
            Guid, //Primary key of the book entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            LineInfos>, //Used to create/update a book
        ILineInfo //implement the IBookAppService
    {
        public IRepository<LineInfo, Guid> _Line;
        public LineServer(IRepository<LineInfo, Guid> Line)
            : base(Line)
        {
            _Line = Line;
        }


        [Route("线路管理显示")]

        /// <summary>
        /// 线路管理
        /// </summary>
        /// <returns></returns>
        //线路管理显示
        public List<LineInfoDto> GetShow()
        {
            var str = (from a in _Line
                       select new LineInfoDto
                       {
                           Id = a.Id,
                           LineId=a.LineId,
                           LineName=a.LineName,
                           LinePoint=a.LinePoint,
                           LineType=a.LineType,
                           LineTime=a.LineTime
                       }).ToList();
            return str;
        }
        [Route("线路管理添加")]
        [HttpPost]
        //线路管理添加
        public async Task<int> GetAdd(LineInfos m)
        {
            LineInfo str = ObjectMapper.Map<LineInfos, LineInfo>(m);
            await _Line.InsertAsync(str);
            return 1;
        }
    }
}
